package com.example.demo;

import javax.security.auth.message.config.RegistrationListener;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextListener;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;

import com.example.demo.listener.SecondListener;
import com.example.demo.servlet.SecondServlet;

@SpringBootApplication
public class SpringbootListener2Application {

	public static void main(String[] args) {
		SpringApplication.run(SpringbootListener2Application.class, args);
	}
	@Bean
	public static ServletRegistrationBean<SecondServlet> getServlet(){
		ServletRegistrationBean<SecondServlet> secondServlet = new ServletRegistrationBean<>(new SecondServlet());
		secondServlet.addUrlMappings("/second");
		return secondServlet;
	}
	@Bean
	public static ServletListenerRegistrationBean getListener() {
		ServletListenerRegistrationBean<SecondListener> listener = new ServletListenerRegistrationBean<>(new SecondListener());
		return listener;
		
	}
	
}
